package 算法.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author:谢君臣
 * @Date:2021/5/25-9:27
 * @version:1.0
 * @function:
 */
public class lc78 {
    public static void main(String[] args) {
        System.out.println(subsets(new int[]{1, 3, 4}));
    }
    public static List<List<Integer>> subsets(int[] nums) {
        List<List<Integer>> res = new ArrayList<>();
        for (int j = 0; j < Math.pow(2,nums.length); j++) {
            int i =j,n = 0;
            List<Integer> temp =new ArrayList<>();
            while (i>>n>0){
                if ((i>>n&1)==1) temp.add(nums[n]);
                n++;
            }
            res.add(temp);
        }
        return res;
    }
}
